var app = getApp(); 
Page({
  /**
   * 页面的初始数据
   */
  data: {
    logourl: '/image/logo.png',
    userName:'',
    password:'',
    message:'',
    jsonresult:''
  },

  nameInput: function (e){
      this.setData({
        userName: e.detail.value
      })
  },

  passwordInput: function (e) {
    this.setData({
      password: e.detail.value
    })
  },

  inputfocus:function(e){
    this.setData({
      message: ""
    })
  },

  login:function(e){
    if (this.data.userName == "" || this.data.password == ""){
      this.setData({
        message:"请完整填写信息"
      })
    }else{
      var that = this
      wx.request({
        url: 'https://eis.natappvip.cc/ITSupport/user_login.action', 
        data: {
          'user.userName': this.data.userName,
          'user.password': this.data.password
        },
        header: { 
          "content-type": "application/x-www-form-urlencoded"
        }, 
        method: "POST",
        success: function (res) {
          let jsonresult =JSON.parse(res.data)
          console.log(jsonresult.result)
          if (jsonresult.result == "error"){
             that.setData({
               message: jsonresult.msg 
            })
          }else{
            app.globalData.user = jsonresult.user 
            console.log(app.globalData.user)
            wx.switchTab({
              url: '../list/list',
            })

          }
        },
        fail: function (err) {
          console.log(err)
        }
      })
    }
  }
})